package book;

import com.sun.org.apache.xpath.internal.operations.Bool;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: a1227
 * Date: 2022-10-04
 * Time: 11:32
 */
//一本书籍的信息
public class Book {
    private String name;//书名
    private String author;//作者
    private String type;//类型
    private int price;//价格
    private boolean state;//借阅状态

    //成员都是private修饰的，所以提供各成员的get和set方法
    public String getName() {

        return name;
    }

    public void setName(String name) {

        this.name = name;
    }

    public String getAuthor() {

        return author;
    }

    public void setAuthor(String author) {

        this.author = author;
    }

    public String getType() {

        return type;
    }

    public void setType(String type) {

        this.type = type;
    }

    public int getPrice() {

        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public boolean getState() {

        return state;
    }

    public void setState(boolean state) {

        this.state = state;
    }

    //Book的构造方法，状态state不用输入，默认是false，未借出状态
    public Book(String name, String author, String type, int price) {
        this.name = name;
        this.author = author;
        this.type = type;
        this.price = price;
    }

    //重写toString，用于打印输出，state为true输出已借出，为false输出未借出
    @Override
    public String toString() {
        return "Book{" +
                "name='" + name + '\'' +
                ", author='" + author + '\'' +
                ", type='" + type + '\'' +
                ", price=" + price +
                ((state == true) ? " 已借出 " : " 未借出 ") +
                '}';
    }
}
